//
//  MineShareVC.m
//  NewPro
//
//  Created by 何荧红 on 2019/2/23.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "MineShareVC.h"
#import "TraditionPOSVC.h"

@interface MineShareVC ()
@property (weak, nonatomic) IBOutlet UIImageView *SQimg;
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *phone;
@property (weak, nonatomic) IBOutlet UILabel *SnNumber;
@property (weak, nonatomic) IBOutlet UILabel *shoplv;

@property (nonatomic, strong) PushView *ShareView;

@end

@implementation MineShareVC
- (void)SetWithDic{
    if (self.dic) {
        self.name.text = _dic[@"merchantName"];
        self.phone.text = _dic[@"phone"];
        self.SnNumber.text = _dic[@"sn"];
        self.shoplv.text = _dic[@"rate"];
        [self.SQimg sd_setImageWithURL:[NSURL URLWithString:_dic[@"SQimg"]]];
        UIImage *small = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_dic[@"SQimg"]]]];
        NSData *data = UIImagePNGRepresentation([ImgManager getSimpleImg:small]);
        self.ShareView.scanQdata = data;
        self.ShareView.weburl = _dic[@"url"];
        self.ShareView.name = [NSString stringWithFormat:@"%@ 邀请你开通商户",[UserDefaultsManager sharedInstance].real_name];
        self.ShareView.subtitle = @"自助报单，方便快捷";
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setNavBarWithTitle:@"自助报单"];
    self.ShareView = [[PushView alloc]initWithShareView];
    [self.view addSubview:self.ShareView];
    [self SetWithDic];
    //注册支付宝通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(GetCodeWithVC:) name:@"MineSureBlock" object:nil];
    
}
- (IBAction)ViewWillPush:(UIButton *)sender {
    [self.ShareView ViewPush:YES];
}
#pragma mark - 自助报单分享回调
- (void)GetCodeWithVC:(NSNotification *)notification{
    NSLog(@"%@",self.navigationController.viewControllers);
    UIViewController *VC = [self.navigationController.viewControllers objectAtIndex:self.navigationController.viewControllers.count -3];
    if ([VC isKindOfClass:[TraditionPOSVC class]]) {
        [[AppDelegate sharedAppDelegate] popToViewController:VC];
    }
}
@end
